package uva;

import rice.p2p.commonapi.Id;
import rice.pastry.NodeHandle;

public class GraphVizEdge {
	private String source;
	private String destination;
	private boolean isBiDirectional;

	public GraphVizEdge(String source, String destination) {
		this.source = source;
		this.destination = destination;
	}

	public String getSource() {
		return normalizeId(source);
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getDestination() {
		return normalizeId(destination);
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public Boolean getIsBiDirectional() {
		return isBiDirectional;
	}

	public void setIsBiDirectional(Boolean isBiDirectional) {
		this.isBiDirectional = isBiDirectional;
	}

	private String normalizeId(String id) {
		for (NodeHandle evilNodeHandle : MaliciousNodes.getInstance()) {
			
			if (id.equals(evilNodeHandle.getId().toStringFull())) {
				return ">!" + id.toString() + "!<";
			}
		}
		return id.toString();

	}

}
